﻿using PLCTest.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PLCTest.BO
{
    public class ZJNDoubleScMessagePlcActionBO
    {
        /// <summary>
        /// 堆垛机手自动（1自动，0手动）
        /// </summary>
        public bool StackerHandAutomatic { get; set; }

        /// <summary>
        /// 堆垛机忙（1空闲，0忙）
        /// </summary>
        public bool StackerBusy { get; set; }

        /// <summary>
        /// 货叉1左伸出
        /// </summary>
        public bool Fork1Extendsleft { get; set; }

        /// <summary>
        /// 货叉1右伸出
        /// </summary>
        public bool Fork1Extendsright { get; set; }

        /// <summary>
        /// 货叉1有盘
        /// </summary>
        public bool Fork1Hasaterial { get; set; }

        /// <summary>
        /// 堆垛机报警
        /// </summary>
        public bool StackerAlarm { get; set; }

        /// <summary>
        /// 堆垛机运行信号
        /// </summary>
        public bool Stackerrunningsignal { get; set; }

        /// <summary>
        /// 堆垛机任务完成
        /// </summary>
        public bool StackerTaskCompletion { get; set; }

        /// <summary>
        /// 安全门在线信号
        /// </summary>
        public bool SecurityDooronLine { get; set; }

        /// <summary>
        /// 请求WSC红外拍照
        /// </summary>
        public bool RequestPhoto { get; set; }

        /// <summary>
        /// 货叉2左伸出
        /// </summary>
        public bool Fork2Extendsleft { get; set; }

        /// <summary>
        /// 货叉2右伸出
        /// </summary>
        public bool Fork2Extendsright { get; set; }

        /// <summary>
        /// 货叉2有盘
        /// </summary>
        public bool Fork2Hasaterial { get; set; }

        /// <summary>
        /// 预留5
        /// </summary>
        public bool yuliu5 { get; set; }

        /// <summary>
        /// 预留6
        /// </summary>
        public bool yuliu6 { get; set; }

        /// <summary>
        /// 预留7
        /// </summary>
        public bool yuliu7 { get; set; }

        /// <summary>
        /// 堆垛机报警代码
        /// </summary>
        public short Stackeralarmcode { get; set; }

        /// <summary>
        /// X轴当前位置
        /// </summary>
        public int Xaxiscurrentposition { get; set; }

        /// <summary>
        /// Y轴当前位置
        /// </summary>
        public int Yaxiscurrentposition { get; set; }

        /// <summary>
        /// 当前行
        /// </summary>
        public short Currentline { get; set; }

        /// <summary>
        /// 当前列
        /// </summary>
        public short Currentcolumn { get; set; }

        /// <summary>
        /// 当前层
        /// </summary>
        public short Currentlayer { get; set; }

        /// <summary>
        /// 当前工作序号1
        /// </summary>
        public int Currentjobnumber { get; set; }

        /// <summary>
        /// 当前工作命令代码（1入库，2出库，3移库，4移动到：货叉不动作）
        /// </summary>
        public short Currentworkordercode { get; set; }
        /// <summary>
        ///  启始行toPC
        /// </summary>
        public short StartlinetoPC { get; set; }
        /// <summary>
        /// 启始列toPC
        /// </summary>
        public short StartcolumntoPC { get; set; }
        /// <summary>
        ///  启始层toPC
        /// </summary>
        public short StartlayertoPC { get; set; }
        /// <summary>
        /// 目标行toPC
        /// </summary>
        public short TargetlinetoPC { get; set; }

        /// <summary>
        /// 目标列toPC
        /// </summary>
        public short TargetcolumntoPC { get; set; }

        /// <summary>
        /// 目标层toPC
        /// </summary>
        public short TargetlayertoPC { get; set; }

        /// <summary>
        /// 当前工作序号2
        /// </summary>
        public int Currentjobnumber2 { get; set; }

        /// <summary>
        /// 堆垛机当前步序号
        /// </summary>
        public short ProgramSteps { get; set; }

        public short yuliu_4 { get; set; }

        public short yuliu_5 { get; set; }

        public short yuliu_6 { get; set; }





        public void Serialize(byte[] bytes)
        {
            //PlcConnectionID = plcConnectionID;
            //PlcReadDbID = plcReadDbID;
            //BytesIndex = bytesIndex;
            //BytesLength = bytesLength;
            //ObjectIndex = objectIndex;
            //ObjectLength = objectLength;
            ///// <summary>
            ///// 约定：
            ///// 1、设备状态报文以State结尾；
            ///// 2、Plc的动作报文以PlcAction结尾；
            ///// 3、Wcs的动作报文以WcsAction结尾；
            ///// 4、平面PLC报文统一PlcState名称
            ///// （后续有其他的再约定）
            ///// </summary>
            //ObjectType = objectType;
            //EquipmentCode = ScEquipmentCode;

            StackerHandAutomatic = HelperByte.GetBitAt(bytes, 0, 0);
            StackerBusy = HelperByte.GetBitAt(bytes, 0, 1);
            Fork1Extendsleft = HelperByte.GetBitAt(bytes, 0, 2);
            Fork1Extendsright = HelperByte.GetBitAt(bytes, 0, 3);
            Fork1Hasaterial = HelperByte.GetBitAt(bytes, 0, 4);
            StackerAlarm = HelperByte.GetBitAt(bytes, 0, 5);
            Stackerrunningsignal = HelperByte.GetBitAt(bytes, 0, 6);
            StackerTaskCompletion = HelperByte.GetBitAt(bytes, 0, 7);

            SecurityDooronLine = HelperByte.GetBitAt(bytes, 1, 0);
            RequestPhoto = HelperByte.GetBitAt(bytes, 1, 1);
            Fork2Extendsleft = HelperByte.GetBitAt(bytes, 1, 2);
            Fork2Extendsright = HelperByte.GetBitAt(bytes, 1, 3);
            Fork2Hasaterial = HelperByte.GetBitAt(bytes, 1, 4);
            yuliu5 = HelperByte.GetBitAt(bytes, 1, 5);
            yuliu6 = HelperByte.GetBitAt(bytes, 1, 6);
            yuliu7 = HelperByte.GetBitAt(bytes, 1, 7);

            Stackeralarmcode = HelperByte.GetIntAt(bytes, 2);
            Xaxiscurrentposition = HelperByte.GetDIntAt(bytes, 4);
            Yaxiscurrentposition = HelperByte.GetDIntAt(bytes, 8);

            Currentline = HelperByte.GetIntAt(bytes, 12);
            Currentcolumn = HelperByte.GetIntAt(bytes, 14);
            Currentlayer = HelperByte.GetIntAt(bytes, 16);
            Currentjobnumber = HelperByte.GetDIntAt(bytes, 18);
            Currentworkordercode = HelperByte.GetIntAt(bytes, 22);

            StartlinetoPC = HelperByte.GetIntAt(bytes, 24);
            StartcolumntoPC = HelperByte.GetIntAt(bytes, 26);
            StartlayertoPC = HelperByte.GetIntAt(bytes, 28);
            TargetlinetoPC = HelperByte.GetIntAt(bytes, 30);
            TargetcolumntoPC = HelperByte.GetIntAt(bytes, 32);
            TargetlayertoPC = HelperByte.GetIntAt(bytes, 34);

            Currentjobnumber2 = HelperByte.GetDIntAt(bytes, 36);
            ProgramSteps = HelperByte.GetIntAt(bytes, 40);
            yuliu_4 = HelperByte.GetIntAt(bytes, 42);
            yuliu_5 = HelperByte.GetIntAt(bytes, 44);
            yuliu_6 = HelperByte.GetIntAt(bytes, 46);
        }

    }
}
